package com.example.eurekaclient.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ： yy
 * @date ：Created in 19-8-21 上午9:42
 * @description：rabbitmq
 * @modified By：
 * @version: $
 */

@RestController
@Slf4j
public class RabbitController {

    /**
     * 直接收myque1 key1的消息，绑定myExchange1
     * @param message
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "MyQue1",durable = "true"),
            key = "key1",
            exchange = @Exchange(value = "MyExchange1",durable = "true")
    ))
    public void listen1(String message){
        log.info("listener1 接收到消息"+message);
    }

    @RabbitListener(queuesToDeclare = @Queue("MyQue1"))
    public void listen2(String message){
        log.info("listener2 接收到消息"+message);
    }


}
